package com.zhouw.printtextview;

import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;

import java.util.HashMap;
import java.util.Map;

/**
 * 银川鸿联科技有限公司
 * 作者 周伟 on 2018-06-08.
 * 邮箱 1300012858@qq.com
 */

public class FontFamily {

    private static Map<String, Typeface> map = new HashMap<>();
    public static Typeface getTypeFace(Context context, String name){
        if(!map.containsKey(name)){
            Typeface typeface = Typeface.createFromAsset(context.getAssets(), name+".ttf");
            if(typeface == null){
                Log.e("PrintTextView","not found typeface named with"+name);
                return null;
            }
            map.put(name, typeface);
        }
        return map.get(name);
    }

}
